import router from '../router';
import storeJs from 'storejs'

/* 公共方法 */
export default {
  install(Vue)  {
    Vue.prototype.isLogin = function (){
      if(storeJs.get("User") == null){
        router.replace({
          path: '/login',
        });
        return false;
      } else {
        return storeJs.get("User");

      }
    };

    Vue.prototype.formatDate = function (value) {
      function add0(m) {
        return m < 10 ? '0' + m : m
      }
      let time = new Date(value*1000);
      let y = time.getFullYear();
      let m = time.getMonth() + 1;
      let d = time.getDate();
      return y + '年' + add0(m) + '月' + add0(d) + '日';
    };
  }
}






